package com.suncaper.wcss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suncaper.wcss.model.domain.RoleFlowSetting;
import com.suncaper.wcss.mapper.RoleFlowSettingMapper;
import com.suncaper.wcss.service.RoleFlowSettingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 审核节点配置 服务实现类
 * </p>
 *
 * @author lxp
 * @since 2021-11-17
 */
@Service
public class RoleFlowSettingServiceImpl extends ServiceImpl<RoleFlowSettingMapper, RoleFlowSetting> implements RoleFlowSettingService {

    @Override
    public RoleFlowSetting getCurNodeByCode(Integer currentNodeCode) {
        QueryWrapper<RoleFlowSetting> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(RoleFlowSetting::getNodeCode,currentNodeCode);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public RoleFlowSetting getNextNodeByCode(Integer auditNodeCode) {
        //先获取本节点
        RoleFlowSetting curNode = getCurNodeByCode(auditNodeCode);
        //再获取本届点的下一个节点
        RoleFlowSetting nextNode = getCurNodeByCode(curNode.getNextNode());
        return nextNode;
    }
}
